<template>
	<view class="richtext_container">
		<rich-text :nodes="dataInfo.valueStr||''"></rich-text>
	</view>
</template>

<script>
	import api from '@/service/config/api.js'
	export default {
		data() {
			return {
				key: '',
				id: '',
				dataInfo: {}
			}
		},
		onLoad(options) {
			if (!options.key && !options.id) {
				return this.$utils.showToast('未找到该页面', 1500, 1)
			}
			if (options.key) {
				this.key = options.key
				return this.getKeyContent()
			}
			if (options.id) {
				this.id = options.id
				// return this.getIdContent()
			}
		},
		methods: {
			getKeyContent() {
				this.$utils.loading()
				api.get('/base/api/tAppletProtocol/inner/type', {
					key: this.key,
					tenantId:uni.getStorageSync("tenantId")
				}).then(res => {
					this.dataInfo = res.data
					if (res.data.keyStr) {
						uni.setNavigationBarTitle({
							title: this.key =="consumer_agreement"?"用户协议":"隐私政策"
						})
					}
				})
			},
			getIdContent() {
				this.$utils.loading()
				api.get('/base/api/tAppletProtocol/' + this.id).then(res => {
					this.dataInfo = res.data
					if (res.data.keyStr) {
						uni.setNavigationBarTitle({
							title: res.data.keyStr
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.richtext_container{
		padding: 40rpx;
	}
</style>